<!DOCTYPE html>
<html>

<head>
<title>类别类型</title>
<meta http-equiv="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit">
<%include("/common/include.html"){}%>
</head>

<body class="easyui-layout">
	<div data-options="region:'center',fit:false,border:false,split:false">
		<div id="contentLayout" class="easyui-layout" data-options="fit:true">
			<div id="table_div" data-options="region:'center',border: false">
				<table id="productTable" style="height: 100%">

				</table>

				<div id="tb" style="height: auto">
					产品类型: <#code id="typeIds" name="productType" class="easyui-combobox" code="code_cplx" style="width:100px"/>
<!-- 					<a href="#" onclick='searchProduct()' class="easyui-linkbutton" iconCls="icon-search">搜索</a> -->
					<% if(authUrl("/productSet/toAddProduct")){ %>
					<a href="#" onclick='addProduct()' class="easyui-linkbutton" iconCls="icon-add">添加</a>
					<% } %>
					<a href="#" class="easyui-linkbutton" iconCls="icon-edit" onclick="editProduct()">修改</a>
					<a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="deleteProduct()">删除</a>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	function searchProduct(){
		var typeIds = $("#typeIds").val();
		var parm = {"_query.typeIds": typeIds};
		$("#productTable").datagrid('load', parm);
	}
	function addProduct(){
		var typeIds = $("#typeIds").val();
		if(typeIds == -1){
			 $.slideMsg("请选择要添加的产品类型！", parent.$);
		}else{
			loadDialog($("#productTable"), null, '添加产品', 'productSet/toAddProduct?ids=' + typeIds);
		}
	}
	function editProduct(){
		 var row = $("#productTable").datagrid('getSelected');
		 if(row == null){
			 $.slideMsg("请选中一条记录！", parent.$);
		 }else{
			 loadDialog($("#productTable"), null, '编辑产品', 'productSet/toUpProduct?ids=' + row.ids);
		 }
	}
	function deleteProduct(){
		 var row = $("#productTable").datagrid('getSelected');
		 if(row == null){
			 $.slideMsg("请选中一条记录！", parent.$);
		 }else{
			 var rowids = row.ids
			 
			 parent.$.messager.confirm('删除','确定删除？',function(r){
				if (r){
					$.post("productSet/productListstruts",{"ids":rowids},function(result){
						$('#productTable').datagrid('reload');
					});
				}
			 });
		 }
	}
	$(function() {
		$('#productTable').datagrid({
			cls: "theme-datagrid",
			toolbar: '#tb',
			singleSelect: true,
			rownumbers: true, //显示序号
			pagination: true,
			pageSize: 10,
			url: "productSet/productList",
			queryParams: {
				'_query.typeIds': $("#typeIds").val()
			},
		    method: 'post',
			collapsible: true,
			columns:[[
				  		{field:'ids',title:'ids',width:100,align:'center', hidden:true},
				  		{field:'probh',title:'编号',width:100,align:'center'},
				  		{field:'name',title:'名称',width:150, align:'center'},
				  		{field:'prospecification',title:'规格',width:160, align:'center'},
				  	/* 	{field:'prounits',title:'单位',width:100, align:'center'},
				  		{field:'procapacity',title:'容量',width:100, align:'center'}, */
				  		{field:'proexperience',title:'有效次数',width:100, align:'center'},
				  		{field:'notsell',title:'非卖品',width:100, align:'center',formatter: function(value,row,index){
			  				var status = row.notsell;
			  				if(status == 1){
				  					return '否';
				  				}else{
				  					return '是';
				  				}
				  			}
				  		} 
// 				  		{field:'status',title:'状态',width:100, align:'center',
// 				  			formatter: function(value,row,index){
// 				  				var status = row.status;
// 				  				if(status == 1){
// 				  					return '<span class='+'l-btn-left'+'><span  style='+'color:red'+' class='+'l-btn-text'+'>正常</span></span></a>';
// 				  				}else{
// 				  					return '<a onclick='+'btn(\'' + row.ids + '\',0)'+' class='+'button-edit button-success  l-btn l-btn-small'+'><span class='+'l-btn-left'+'><span  style='+'color:green'+' class='+'l-btn-text'+'>禁用</span></span></a>';
// 				  				}
// 				  			}
// 				  		}
				      ]],
			onLoadSuccess:function(){
				
			}
		});
		$('#typeIds').combobox({
	        onChange:function(){
	        	searchProduct();
			}
		});
	})
	</script>

</body>